<?php 
/**
*区域总监
*/
require("./include/init.php");
//取出北区的数据
$mysql=mysql::getIns();
@$address=$_REQUEST['address'];

if($address==''){
	$address="北京博瑞祥星汽车销售有限公司";
}
date_default_timezone_set('Asia/Shanghai');

$maxtime=time();
$mintime=$maxtime-10*60;
// echo $maxtime . '<br />';
// echo $mintime;
$sql="select count(*) from alldev where timestamp > $mintime and timestamp < $maxtime and shop='". $address ."'";
$allnow=$mysql->getOne($sql);
// echo $allnow;
// print_r($allnow);
// exit;


//统计当天累计人数数
$t = time();
$start = mktime(0,0,0,date("m",$t),date("d",$t),date("Y",$t));
$end = mktime(23,59,59,date("m",$t),date("d",$t),date("Y",$t));
$sql="select count(*) from alldev where timestamp > $start and timestamp < $end and shop='" . $address . "'";
$allday=$mysql->getOne($sql);

//首次今天首次进店人数,通过字段visittimes为1来进行判断
$sql="select count(*) from alldev where visittimes=1 and timestamp > $mintime and timestamp < $maxtime and shop='".$address ."'";
$first=$mysql->getOne($sql);

//统计当前销售区
$sql="select count(*) from alldev where timestamp > $mintime and timestamp < $maxtime and shop='" . $address ."' and area in ('展厅区','销售区','精品区')";
$sale=$mysql->getOne($sql);
// echo $sale;
// print_r($sale);
// exit;

//统计当前售后区
$service=$allnow-$sale;


//今天多次进店人数
$sql="select count(*) from alldev where visittimes <> 1 and timestamp > $mintime and timestamp < $maxtime and shop='" . $address ."'";
$second=$mysql->getOne($sql);

//统计登陆人数
$sql="select count(*) from alldev where isOL=1 and timestamp > $mintime and timestamp < $maxtime and shop='" . $address ."'";
$login=$mysql->getOne($sql);
// echo $login;

//统计未登陆人数
$sql="select count(*) from alldev where isOL=2 and timestamp > $mintime and timestamp < $maxtime and shop='" . $address ."'";
$nolog=$mysql->getOne($sql);

//统计历史进店人数
$sql="select count(*) from alldev where shop='". $address ."'";
$history=$mysql->getOne($sql);
$data=include('./include/history.inc.php');
// print_r($data);
$b=$data["$address"];
$history+=$b;


require(ROOT . 'view/iwocar5/Area_Main.html');
 ?>